package com.demo.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

import com.demo.plugin.IocInterceptor;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;

@Before(IocInterceptor.class)
public class BlogController extends Controller {

	@Autowired
	public void setApplicationContext(ApplicationContext ctx) {
		System.out.println("HelloController attr[ApplicationContext] 已出入。。");
	}

	public void index() {
		renderJsp("index.jsp");
	}

	public void t() throws Exception {
		HttpServletRequest req = getRequest();
		HttpServletResponse resp = getResponse();

		String attributeName = req.getParameter("attributeName");
		String attributeValue = req.getParameter("attributeValue");
		req.getSession().setAttribute(attributeName, attributeValue);
		index();
	}
}
